<?php

    require_once(realpath(dirname(__FILE__)."/../../../globals.php"));
    $mikron->Page->StartBody();

    // Новости
    
    $entityname = "T_NEWS";
    $returntext = "Перейти к списку &rarr;";
    $razdel = "Архив новостей";
     
    if(isset($_REQUEST['item']) && is_numeric($_REQUEST['item']))
    {
        $id = (int)$_REQUEST['item'];
        $news = new $entityname($id);
        echo $news->toString();
        ?><p><a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>"><?php echo $returntext; ?></a></p><?php
    }
    else
    {
        ?><h4><?php echo $razdel; ?></h4>&nbsp;<ul class="list1"><?php
        ?><ul class="list1"><?php
        $items = $mikron->Queries->Query($entityname);
        while($item = $items->fetch())
        {
            $id = $item->id;
            $anons = $item->anons->value;
            $text = $item->text->value;
            echo "<li><a class=\"link2\" href=\"?item=$id\">$anons</a><br />&nbsp;</li>";
        }
        echo "</ul>";
    }

$mikron->Page->EndBody();
?>